<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShortUrl extends Migrator
{
    public function up()
    {
        $table = $this->table('short_url', ['id' => 'id', 'comment' => '短链接', 'engine' => 'InnoDB', '']);
        $table->addColumn('params', 'string', ['limit' => 1000, 'default' => '', 'comment' => '用户名']);
        $table->addColumn('url', 'string', ['limit' => 200, 'default' => '', 'comment' => '跳转链接']);
        $table->addColumn('agent_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '代理id'])
            ->addColumn('channel_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '渠道id'])
            ->addColumn('user_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '用户id'])
            ->addTimestamps()//默认生成create_time和update_time两个字段
            ->create();
    }

    public function down()
    {
        $this->dropTable('short_url');

    }
}
